using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DTO;
using BUS;

namespace GUI
{
    public partial class TraCuuChuyenDuLichTheoThoiGianKhoiHanhGUI : Form
    {
        public TraCuuChuyenDuLichTheoThoiGianKhoiHanhGUI()
        {
            InitializeComponent();
        }

        public void ShowMaster()
        {
            this.dgvChuyenDL.AutoGenerateColumns = false;
            DateTime thoiGianKhoiHanh = DateTime.Parse(this.cbThoiGianKhoiHanh.SelectedValue.ToString());
            this.dgvChuyenDL.DataSource = DuLichBUS.SelectChuyenDuLichAndTenTuyenDuLichByThoiGianKhoiHanh(thoiGianKhoiHanh);
        }

        private void TraCuuChuyenDuLichTheoThoiGianKhoiHanhGUI_Load(object sender, EventArgs e)
        {
            this.cbThoiGianKhoiHanh.ValueMember = "ThoiGianKhoiHanh";
            this.cbThoiGianKhoiHanh.DisplayMember = "ThoiGianKhoiHanh";
            this.cbThoiGianKhoiHanh.DataSource = ChuyenDuLichBUS.SelectThoiGianKhoiHanh();

            this.ShowMaster();
        }

        private void cbThoiGianKhoiHanh_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.ShowMaster();
        }

        private void dgvChuyenDL_SelectionChanged(object sender, EventArgs e)
        {
            if (this.dgvChuyenDL.CurrentRow != null)
            {
                this.tbMaChuyenDL.Text = this.dgvChuyenDL.CurrentRow.Cells["MaChuyenDL"].Value.ToString();
                this.tbTongThoiGian.Text = this.dgvChuyenDL.CurrentRow.Cells["TongThoiGian"].Value.ToString();
                this.tbTenTuyenDL.Text = this.dgvChuyenDL.CurrentRow.Cells["TenTuyenDL"].Value.ToString();
            }
        }
    }
}